class NoisyImageController < ApplicationController
  
  
  # 產生驗證圖片物件,並填入 Session 中.
#  def protect
#    session[:noisy_image] = nil
#    unless session[:noisy_image]
#      session[:noisy_image] = NoisyImage.new(4)
#      session[:code] = session[:noisy_image].code
#    end
#  end

  # 產生驗證圖片.
  def code_image
    image = session[:noisy_image].code_image
    send_data image, :type => 'image/jpeg', :disposition => 'inline'
  end

  # 檢查使用主輸入的值是否等於驗證圖片上的值.
#  def check_code
#    typed_code = params[:typed_code]
#    unless typed_code == session[:noisy_image].code
#      flash[:notice] = "Please type in the correct code" 
#      redirect_to(:action => "put_noisy_image_into_session") and return false
#    end
#    redirect_to(:controller => "FormController", :action => "show_form")
#  end
  
end
